import java.util.Scanner;

public class Leetcode_7 {
    public static void main(String[] args) {
        System.out.println("请输入一句英语：");
        Scanner S = new Scanner(System.in);
        String arr = S.next();
        int index = arr.length() - 1;
        while(arr.charAt(index) == ' '){
            index--;
        }
        int index_1 = 0;
        while(index >= 0 && arr.charAt(index) != ' '){
            index_1++;
            index--;
        }
        System.out.println("最后一个单词的长度为："+index_1);
    }
}
